//
//  ZCBarButtonItem.swift
//  weibo
//
//  Created by 张城 on 16/7/19.
//  Copyright © 2016年 张城. All rights reserved.
//

import UIKit

class ZCBarButtonItem: UIBarButtonItem {
    
    
    init(title: String? = nil,imgName: String? = nil,target: AnyObject?,action: Selector) {
        super.init()
        
        let  button = UIButton()
        
        if let til = title {
            button.setTitle(til, forState: .Normal)
            button.setTitleColor(UIColor.orangeColor(), forState: .Normal)
            button.setTitleColor(UIColor.grayColor(), forState: .Disabled)
            button.titleLabel?.font = UIFont.systemFontOfSize(15)
        }
        
        if let img = imgName {
            button.setImage(UIImage(named: img), forState: .Normal)
        }
        
        
        button.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        button.sizeToFit()
        self.customView = button
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }


}
